//------------------------------------------------------------------------------
// <copyright file="ViewModelBase.cs" company="Damian Antonowicz">
//       copyright © 2010 Damian Antonowicz
// </copyright>
// <author>Damian Antonowicz</author>
// <email>poczta@damianantonowicz.pl</email>
//------------------------------------------------------------------------------

using System.ComponentModel;
using DotBeer.UI.WPFClient.Commands;
using System.Diagnostics;
using DotBeer.Business.Components.Exceptions;

namespace DotBeer.UI.WPFClient.ViewModels
{
    /// <summary>
    /// Provides common functionality for ViewModel classes
    /// </summary>
    public abstract class ViewModelBase : INotifyPropertyChanged
    {
        #region private members

        DelegateCommand helpCommand;

        #endregion

        #region properties

        public event PropertyChangedEventHandler PropertyChanged;

        #region commands

        public DelegateCommand HelpCommand
        {
            get
            {
                if (this.helpCommand == null)
                    this.helpCommand = new DelegateCommand(this.ShowHelp);

                return this.helpCommand;
            }
        }

        #endregion

        #endregion

        #region private methods

        private void ShowHelp()
        {
            HandleExceptions.UIPolicy(() => Process.Start("http://dotbeer.codeplex.com/documentation"));
        }

        #endregion
    }
}
